package com.project.mapper.CgwMapper;

import com.Entity.DzmHisMemberEntity;
import com.Entity.DzmHisSchedulingEntity;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;


@Mapper
public interface LogingDao {

    @Select("select * from dzm_his_member where user_name=#{userName} and password=#{password}")
    DzmHisMemberEntity query(DzmHisMemberEntity dzmHis);


    @SelectProvider(type =OrderProvider.class, method = "queryOrderByParam")
    List<Map<String,Object>> querys(DzmHisMemberEntity dzmHis);

    //排班的下拉框显示
    @Select("select reg_id,registeredfee_name from  dzm_his_registeredfee")
    List<Map<String,Object>> selec();

    //我的排班
    @Select("SELECT * FROM dzm_his_scheduling a, dzm_his_scheduling_subsection b, dzm_his_scheduling_week c, dzm_his_registeredfee d " +
            " WHERE a.scheduling_id = b.scheduling_id AND c.scheduling_subsection_id=b.scheduling_subsection_id and c.registeredfee_id=d.reg_id and a.physicianid=#{physicianid} and a.department_id=#{department_id}")
    List<Map<String,Object>> paiban(int department_id,int physicianid);

    //本周
    @Select("SELECT * FROM dzm_his_scheduling a,dzm_his_scheduling_subsection b,dzm_his_scheduling_week c WHERE a.scheduling_id = b.scheduling_id AND c.scheduling_subsection_id = b.scheduling_subsection_id AND b.scheduling_id = ( SELECT scheduling_id FROM dzm_his_scheduling WHERE (start_time_this_week BETWEEN #{start_time_this_week} AND #{end_time_this_week}) AND (end_time_this_week BETWEEN #{start_time_this_week} AND #{end_time_this_week})AND department_id = #{department_id} and physicianid = #{physicianid})")
    List<Map<String,Object>>Selecctductor(Map<String,Object>mapsp);




    @Insert("INSERT INTO `openhis`.`dzm_his_scheduling` ( `physicianid`, `department_id`, `company_id`, `start_time_this_week`, `end_time_this_week`, `create_time`, `update_time`) " +
            "VALUES (#{physicianid}, #{department_id}, '2', #{start_time_this_week}, #{end_time_this_week}, #{create_time}, #{update_time});\n")
    int spec(Map<String,Object>msqp);


    @Select("SELECT scheduling_id FROM dzm_his_scheduling WHERE start_time_this_week between #{start_time_this_week} and #{start_time_this_week} and end_time_this_week between #{end_time_this_week} and #{end_time_this_week} and department_id=#{department_id} AND physicianid=#{physicianid}")
    int scheduling_id(Map<String,Object> msp);

    @Insert("insert into dzm_his_scheduling_subsection(subsection_type, scheduling_id) values (1,#{scheduling_id}),(2,#{scheduling_id}),(3,#{scheduling_id})")
    int insertCollectList(int scheduling_id);

    @Select("select scheduling_subsection_id from dzm_his_scheduling_subsection where scheduling_id=#{scheduling_id}")
    List<Integer>lis(int scheduling_id);

    @Insert("INSERT INTO `openhis`.`dzm_his_scheduling_week` " +
            "( `date`, `week`, `registeredfee_id`, `scheduling_subsection_id`) VALUES " +
            "(#{date0}, '1', #{registeredfee_id0}, #{scheduling_subsection_id0})," +
            "(#{date1}, '2', #{registeredfee_id1}, #{scheduling_subsection_id0})," +
            "(#{date2}, '3', #{registeredfee_id2}, #{scheduling_subsection_id0})," +
            "(#{date3}, '4', #{registeredfee_id3}, #{scheduling_subsection_id0})," +
            "(#{date4}, '5', #{registeredfee_id4}, #{scheduling_subsection_id0})," +
            "(#{date5}, '6', #{registeredfee_id5}, #{scheduling_subsection_id0})," +
            "(#{date6}, '0', #{registeredfee_id6}, #{scheduling_subsection_id0})," +
            "(#{date0}, '1', #{registeredfee_id7}, #{scheduling_subsection_id1})," +
            "(#{date1}, '2', #{registeredfee_id8}, #{scheduling_subsection_id1})," +
            "(#{date2}, '3', #{registeredfee_id9}, #{scheduling_subsection_id1})," +
            "(#{date3}, '4', #{registeredfee_id10}, #{scheduling_subsection_id1})," +
            "(#{date4}, '5', #{registeredfee_id11}, #{scheduling_subsection_id1}),(" +
            "#{date5}, '6', #{registeredfee_id12}, #{scheduling_subsection_id1})," +
            "(#{date6}, '0', #{registeredfee_id13}, #{scheduling_subsection_id1})," +
            "(#{date0}, '1', #{registeredfee_id14}, #{scheduling_subsection_id2})," +
            "(#{date1}, '2', #{registeredfee_id15}, #{scheduling_subsection_id2})," +
            "(#{date2}, '3', #{registeredfee_id16}, #{scheduling_subsection_id2})," +
            "(#{date3}, '4', #{registeredfee_id17}, #{scheduling_subsection_id2})," +
            "(#{date4}, '5', #{registeredfee_id18}, #{scheduling_subsection_id2})," +
            "(#{date5}, '6', #{registeredfee_id19}, #{scheduling_subsection_id2})," +
            "(#{date6}, '0', #{registeredfee_id20}, #{scheduling_subsection_id2});\n")
    int sp(Map<String,Object>spea);


    @Update("update dzm_his_scheduling_week " +
            "SET registeredfee_id=#{registeredfee_id} " +
            "where scheduling_subsection_id = #{scheduling_subsection_id} and date = #{date}")
    void psssd(Map<String, Object> lis1);

    @Update("update dzm_his_scheduling_week" +
            " SET registeredfee_id=#{registeredfee_id} where " +
            "scheduling_subsection_id = #{scheduling_subsection_id}and date = #{date}")
    void psssd1(Map<String, Object> lis2);

    @Update("update dzm_his_scheduling_week" +
            " SET registeredfee_id=#{registeredfee_id} where " +
            "scheduling_subsection_id = #{scheduling_subsection_id}and date = #{date}")
    void psssd2(Map<String, Object> lis3);

    @Update("update dzm_his_scheduling_week" +
            " SET registeredfee_id=#{registeredfee_id} where " +
            "scheduling_subsection_id = #{scheduling_subsection_id}and date = #{date}")
    void psssd3(Map<String, Object> lis4);

    @Update("update dzm_his_scheduling_week" +
            " SET registeredfee_id=#{registeredfee_id} where " +
            "scheduling_subsection_id = #{scheduling_subsection_id}and date = #{date}")
    void psssd4(Map<String, Object> lis5);

    @Update("update dzm_his_scheduling_week" +
            " SET registeredfee_id=#{registeredfee_id} where " +
            "scheduling_subsection_id = #{scheduling_subsection_id}and date = #{date}")
    void psssd5(Map<String, Object> lis6);

    @Update("update dzm_his_scheduling_week" +
            " SET registeredfee_id=#{registeredfee_id} where " +
            "scheduling_subsection_id = #{scheduling_subsection_id}and date = #{date}")
    void psssd6(Map<String, Object> lis7);

    @Update("update dzm_his_scheduling_week" +
            " SET registeredfee_id=#{registeredfee_id} where " +
            "scheduling_subsection_id = #{scheduling_subsection_id}and date = #{date}")
    void psssd7(Map<String, Object> lis8);

    @Update("update dzm_his_scheduling_week" +
            " SET registeredfee_id=#{registeredfee_id} where " +
            "scheduling_subsection_id = #{scheduling_subsection_id}and date = #{date}")
    void psssd8(Map<String, Object> lis9);

    @Update("update dzm_his_scheduling_week" +
            " SET registeredfee_id=#{registeredfee_id} where " +
            "scheduling_subsection_id = #{scheduling_subsection_id}and date = #{date}")
    void psssd9(Map<String, Object> lis10);

    @Update("update dzm_his_scheduling_week" +
            " SET registeredfee_id=#{registeredfee_id} where " +
            "scheduling_subsection_id = #{scheduling_subsection_id}and date = #{date}")
    void psssd10(Map<String, Object> lis11);

    @Update("update dzm_his_scheduling_week" +
            " SET registeredfee_id=#{registeredfee_id} where " +
            "scheduling_subsection_id = #{scheduling_subsection_id}and date = #{date}")
    void psssd11(Map<String, Object> lis12);

    @Update("update dzm_his_scheduling_week" +
            " SET registeredfee_id=#{registeredfee_id} where " +
            "scheduling_subsection_id = #{scheduling_subsection_id}and date = #{date}")
    void psssd12(Map<String, Object> lis13);

    @Update("update dzm_his_scheduling_week" +
            " SET registeredfee_id=#{registeredfee_id} where " +
            "scheduling_subsection_id = #{scheduling_subsection_id}and date = #{date}")
    void psssd13(Map<String, Object> lis14);

    @Update("update dzm_his_scheduling_week" +
            " SET registeredfee_id=#{registeredfee_id} where " +
            "scheduling_subsection_id = #{scheduling_subsection_id}and date = #{date}")
    void psssd14(Map<String, Object> lis15);

    @Update("update dzm_his_scheduling_week" +
            " SET registeredfee_id=#{registeredfee_id} where " +
            "scheduling_subsection_id = #{scheduling_subsection_id}and date = #{date}")
    void psssd15(Map<String, Object> lis16);

    @Update("update dzm_his_scheduling_week" +
            " SET registeredfee_id=#{registeredfee_id} where " +
            "scheduling_subsection_id = #{scheduling_subsection_id}and date = #{date}")
    void psssd16(Map<String, Object> lis17);

    @Update("update dzm_his_scheduling_week" +
            " SET registeredfee_id=#{registeredfee_id} where " +
            "scheduling_subsection_id = #{scheduling_subsection_id}and date = #{date}")
    void psssd17(Map<String, Object> lis18);

    @Update("update dzm_his_scheduling_week" +
            " SET registeredfee_id=#{registeredfee_id} where " +
            "scheduling_subsection_id = #{scheduling_subsection_id}and date = #{date}")
    void psssd18(Map<String, Object> lis19);

    @Update("update dzm_his_scheduling_week" +
            " SET registeredfee_id=#{registeredfee_id} where " +
            "scheduling_subsection_id = #{scheduling_subsection_id}and date = #{date}")
    void psssd19(Map<String, Object> lis20);

    @Update("update dzm_his_scheduling_week" +
            " SET registeredfee_id=#{registeredfee_id} where " +
            "scheduling_subsection_id = #{scheduling_subsection_id}and date = #{date}")
    void psssd20(Map<String, Object> lis21);



    @Select("select * from dzm_patient a,dzm_his_patient_file b where a.patient_id=b.patient_id;\n")
    List<Map<String,Object>>lp();


    @Select("select * from dzm_patient where patient_id=#{pid}")
    List<Map<String,Object>>hz(String pid);
}
